<template>
  <div class="self">
    <s-outlogin v-if="!signed"/>
    <s-top v-on:dosocket='dosocket' v-if="signed"/>
    <s-bottom ref="bottom"></s-bottom>
    <div class="quit" v-if="signed" @click="e_login">
      <v-button :text="quit"></v-button>
    </div>
  </div>
</template>

<script>
  import { mapState, mapMutations } from 'vuex'
  import outloginSelf from './outloginSelf'
  import selfTop from './selfTop'
  import selfBottom from './selfBottom'
  import VButton from '@c/button/button'

  export default {
    name: 'self',
    data() {
      return {
        quit: '退出登录',
      }
    },
    sockets: {
      connect: function() {
        debugger
        console.log('连接成功')
      },
      customEmit: function(val) {
        console.log(
          'this method was fired by the socket server. eg: io.emit("customEmit", data)',
        )
      },
    },

    components: {
      's-outlogin': outloginSelf,
      's-top': selfTop,
      's-bottom': selfBottom,
      VButton,
    },

    computed: {
      ...mapState(['wtitle', 'tabSelectID', 'signed']),
    },

    methods: {
      ...mapMutations(['WTITLE', 'TABSELECTID']),
      e_login() {
        this.$store.state.signed = false
        window.localStorage.clear()
        this.$refs.bottom.getAuctionLength()
      },
      dosocket() {
        this.$socket.emit('emit_method', 'ddd')
      },
    },

    mounted() {
      // 此方法 是为了解决Vuex在页面刷新 状态失效的情况
      this.TABSELECTID(sessionStorage.getItem('tabSelectID'))
    },
  }
</script>
